import request from '@/utils/request'
import { SaveMenu } from '@/interface/auth/menu'
// import { ResMenuTree, MenuQuery, SaveMenu } from '@/model/system/MenuTree'

/**
 * 获取所有菜单
 * @param data
 * @returns
 */
export function getMenuApi(data: any): Promise<null> {
  return request.get('/api/auth/module/list', data)
}
/**
 * 新增菜单
 * @param data
 * @returns
 */
export function addMenuApi(data:SaveMenu): Promise<null> {
  const params = data // 解决eslint提示 禁止对函数参数再赋值
  if (params.parentId == null) params.parentId = 0
  return request.post('/api/auth/module', params)
}
/**
 * 修改菜单
 * @param data
 * @returns
 */
export function updateMenuApi(id:number, data: SaveMenu): Promise<null> {
  const params = data // 解决eslint提示 禁止对函数参数再赋值
  if (params.parentId == null) params.parentId = 0
  return request.put(`/api/auth/module/${id}`, params)
}
/**
 * 删除菜单
 * @param id
 */
export function deleteMenuApi(id: number): Promise<null> {
  return request.delete(`/api/auth/module/${id}`)
}
